<?php

/** <p>Relating to API authentication and access limits, can occur with all API classes.</p>
 * 
 * <table>
 *   <tr><th>Code</th><th>Message</th><th>Occurs when</th></tr>
 *   <tr><td>100</td><td>key invalid</td><td>Accessing the API with a key that is not valid i.e. does not exist or has been deleted.</td></tr>
 *   <tr><td>101</td><td>key suspended</td><td>Accessing the API with a key that has been suspended.</td></tr>
 *   <tr><td>102</td><td>key not allowed access to specified resource</td><td>Accessing an API method with a key that is not allowed to perform the requested action.</td></tr>
 *   <tr><td>103</td><td>request limit reached</td><td>Client IP has reached the request limit.</td></tr>
 *   <tr><td>104</td><td>invalid email address or password</td><td>Requesting a key using invalid account credentials.</td></tr>
 *   <tr><td>99</td><td>An unexpected APi access error occurred</td><td></td></tr>
 * </table>
 *
 * @package com\hostingreborn\api
 *
 * @author      Jon Cram <jon@hostingreborn.com>
 * @copyright   https://api.hostingreborn.com/code/copyright/
 * @license     https://api.hostingreborn.com/code/license/
 * @version     1.0
 *
 *
 */
class HR_apiAccessException extends Exception {

};


/** <p>Relating to internal system errors, can occur with all API classes.</p>
 * 
 * <table>
 *   <tr><th>Code</th><th>Message</th><th>Occurs when</th></tr>
 *   <tr><td>100</td><td>System exception: unknown system error</td><td>One or more systems on which the API depends failed in a non-recoverable way (something crashed).</td></tr>
 * </table>
 *
 * @package com\hostingreborn\api
 *
 * @author      Jon Cram <jon@hostingreborn.com>
 * @copyright   https://api.hostingreborn.com/code/copyright/
 * @license     https://api.hostingreborn.com/code/license/
 * @version     1.0
 *
 *
 */
class HR_apiBackendSystemException extends Exception {

};


/** <p>When a request results in one or more database errors within the API, can occur with all API classes.</p>
 *
 *
 * @package com\hostingreborn\api
 *
 * @author      Jon Cram <jon@hostingreborn.com>
 * @copyright   https://api.hostingreborn.com/code/copyright/
 * @license     https://api.hostingreborn.com/code/license/
 * @version     1.0
 *
 *
 */
class HR_apiDatabaseException extends Exception {

};

/** <p>Relating to issues with an account, occurs with <a href="hr_accountapi.html">HR_accountApi</a>, <a href="hr_hostingaccountapi.html">HR_hostingaccountApi</a>.</p>
 *
 * <table>
 *   <tr><th>Code</th><th>Message</th><th>Occurs when</th></tr>
 *   <tr><td>101</td><td>action disallowed - account overdrawn</td><td>Performing an action that requires your account to be in credit, such as adding a new hosting account</td></tr>
 *   <tr><td>200</td><td>password reset failed</td><td></td></tr>
 *   <tr><td>201</td><td>new email address already taken</td><td>Changing your account email address to one that is taken by another account</td></tr>
 *   <tr><td>202</td><td>new password not sufficiently strong</td><td>Choosing an insecure password when resetting your account password/td></tr>
 *   <tr><td>99</td><td>An unexpected account error occurred</td><td></td></tr>
 * </table>
 *
 * @package com\hostingreborn\api
 *
 * @author      Jon Cram <jon@hostingreborn.com>
 * @copyright   https://api.hostingreborn.com/code/copyright/
 * @license     https://api.hostingreborn.com/code/license/
 * @version     1.0
 *
 *
 */
class HR_apiAccountException extends Exception {

};


/** <p>When the response from the API cannot be used, can occur with all API classes.</p>
 * 
 * <table>
 *   <tr><th>Code</th><th>Message</th><th>Occurs when</th></tr>
 *   <tr><td>100</td><td>no response from &lt;url&gt;</td><td>The API does not respond to all to a request.</td></tr>
 *   <tr><td>101</td><td>API server returned malformed response</td><td>The API returns a response that cannot be understood.</td></tr>
 * </table>
 *
 * @package com\hostingreborn\api
 *
 * @author      Jon Cram <jon@hostingreborn.com>
 * @copyright   https://api.hostingreborn.com/code/copyright/
 * @license     https://api.hostingreborn.com/code/license/
 * @version     1.0
 *
 *
 */
class HR_apiResponseException extends Exception {
    private $responseText;

    /**
     *
     * @param string $message
     * @param int $code
     * @param string $responseText
     */
    public function __construct($message = '', $code = 0, $responseText = '') {
        parent::__construct($message, $code);
        $this->responseText = $responseText;
    }

};

/** <p>Relating to issues with a hosting account, occurs with <a href="hr_hostingaccountapi.html">HR_hostingaccountApi</a>.</p>
 *
 * <table>
 *   <tr><th>Code</th><th>Message</th><th>Occurs when</th></tr>
 *   <tr><td>100</td><td>User name invalid</td><td>Providing an invalid user name when creating a new hosting account</td></tr>
 *   <tr><td>101</td><td>Domain name invalid</td><td>Providing an invalid domain name when creating a new hosting account</td></tr>
 *   <tr><td>102</td><td>Domain name taken</td><td>Providing a domain name already used by another hosting account when creating a new hosting account</td></tr>
 *   <tr><td>103</td><td>User name taken</td><td>Proving a username already taken by another hosting account when creating a new hosting account</td></tr>
 *   <tr><td>104</td><td>No working servers found</td><td>No working hosting servers could be found when creating a new hosting account</td></tr>
 *   <tr><td>105</td><td>All servers have reached their storage limits</td><td>No hosting servers with free space could be found when creating a new hosting account</td></tr>
 *   <tr><td>200</td><td>password reset failed</td><td></td></tr>
 *   <tr><td>201</td><td>action failed as hosting account is suspended</td><td></td></tr>
 *   <tr><td>99</td><td>Unknown error</td><td></td></tr>
 * </table>
 *
 * @package com\hostingreborn\api
 *
 * @author      Jon Cram <jon@hostingreborn.com>
 * @copyright   https://api.hostingreborn.com/code/copyright/
 * @license     https://api.hostingreborn.com/code/license/
 * @version     1.0
 *
 *
 */
class HR_apiHostingAccountException extends Exception {

};


/** <p>For errors not handled directly by the core API class, <i>must</i> be handled by any class extending the core API.</p>
 *
 * @package com\hostingreborn\api
 *
 * @author      Jon Cram <jon@hostingreborn.com>
 * @copyright   https://api.hostingreborn.com/code/copyright/
 * @license     https://api.hostingreborn.com/code/license/
 * @version     1.0
 *
 *
 */
class HR_apiResponseUnhandledException extends Exception {

    /**
     *
     * @var string $apiExceptionType
     */
    private $apiExceptionType;


    /**
     *
     * @var string $apiExceptionMessage
     */
    private $apiExceptionMessage;


    /**
     *
     * @var int $apiExceptionCode
     */
    private $apiExceptionCode;


    /**
     *
     * @param string $message Exception message, passed to Exception::__construct()
     */
    public function __construct($message) {
        parent::__construct($message);
    }


    /**
     *
     * @param string $type
     * @param string $message
     * @param string $code
     */
    public function setApiExceptionDetails($type, $message, $code) {
        $this->apiExceptionType = $type;
        $this->apiExceptionMessage = $message;
        $this->apiExceptionCode = $code;
    }


    /**
     *
     * @return string
     */
    public function getApiExceptionType() {
        return $this->apiExceptionType;
    }


    /**
     *
     * @return string
     */
    public function getApiExceptionMessage() {
        return $this->apiExceptionMessage;
    }


    /**
     *
     * @return int
     */
    public function getApiExceptionCode() {
        return $this->apiExceptionCode;
    }

};


/** <p>Relating to issues with servers, occurs with <a href="hr_serverapi.html">HR_serverApi</a>.</p>
 *
 * <table>
 *   <tr><th>Code</th><th>Message</th><th>Occurs when</th></tr>
 *   <tr><td>310</td><td>not found</td><td>Requesting details of a server that does not existe</td></tr>
 *   <tr><td>99</td><td>Unknown error</td><td></td></tr>
 * </table>
 *
 * @package com\hostingreborn\api
 *
 * @author      Jon Cram <jon@hostingreborn.com>
 * @copyright   https://api.hostingreborn.com/code/copyright/
 * @license     https://api.hostingreborn.com/code/license/
 * @version     1.0
 *
 *
 */
class HR_apiServerException extends Exception {

};

?>